import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { CascaderOption } from '@iux/live/cascader/interface';

const defaultOptions = [
  {
    value: 'zhejiang',
    label: 'Zhejiang',
    children: [
      {
        value: 'hangzhou',
        label: 'Hangzhou',
        children: [
          {
            value: 'xihu',
            label: 'West Lake',
            isLeaf: true,
          },
        ],
      },
      {
        value: 'ningbo',
        label: 'Ningbo',
        isLeaf: true,
      },
    ],
  },
  {
    value: 'jiangsu',
    label: 'Jiangsu',
    children: [
      {
        value: 'nanjing',
        label: 'Nanjing',
        children: [
          {
            value: 'zhonghuamen',
            label: 'Zhong Hua Men',
            isLeaf: true,
          },
        ],
      },
    ],
  },
];

@Component({
  selector: 'app-basic',
  templateUrl: './filter.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FilterComponent implements OnInit {
  options: CascaderOption[];

  values: string[] | null = null;

  ngOnInit(): void {
    this.options = defaultOptions;
  }

  onChanges(values: any): void {
    console.log(values);
  }

  filterChange(value: string): void {
    console.log('searching: ', value);
  }
}
